package beike;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Second {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[][] times=new int[n][2];
        for (int i = 0; i < n; i++) {
            times[i][0]=sc.nextInt();
            times[i][1]=sc.nextInt();
        }
        Arrays.sort(times,(a,b)->((a[0]-b[0])!=0?(a[0]-b[0]):(b[1]-a[1])));

        StringBuilder sb=new StringBuilder();
        boolean flag=false;
        List<Integer> list=new LinkedList<>();
        for (int i = 1; i < n; i++) {
            if(times[i][0]<times[i-1][1]) {
                flag=true;
                break;
            }

        }
        if(flag) {
            System.out.println(0);
            return;
        }
        System.out.println(n);
        for (int i = 0; i < n; i++) {
            if(i==0) sb.append(i+1);
            else sb.append(" ").append(i+1);
        }
        System.out.println(sb.toString());

    }
}
